﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace MyBlog.ServiceInterface
{
   public interface IBaseService<T> where T:class
   {
       /// <summary>
       /// 添加实体
       /// </summary>
       /// <param name="model"></param>
       void Add(T model);

       /// <summary>
       /// 批量添加实体
       /// </summary>
       /// <param name="models"></param>
       void AddRange(IEnumerable<T> models);

       /// <summary>
       /// 更新实体
       /// </summary>
       /// <param name="model"></param>
       void Update(T model);

       /// <summary>
       /// 根据主键删除实体
       /// </summary>
       /// <param name="primaryKey"></param>
       void Delete(params object[] primaryKey);

       /// <summary>
       /// 通过实体条件删除实体
       /// </summary>
       /// <param name="model"></param>
       void Delete(T model);

       /// <summary>
       /// 批量删除实体
       /// </summary>
       /// <param name="models"></param>
       void DeleteRange(IEnumerable<T> models);

       /// <summary>
       /// 根据主键获得实体
       /// </summary>
       /// <param name="primaryKey"></param>
       /// <returns></returns>
       T Get(params object[] primaryKey);

       /// <summary>
       /// 根据实体条件获得实体
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       T Get(T model);

       /// <summary>
       /// 获取所有实体的集合
       /// </summary>
       /// <returns></returns>
       List<T> GetAll(bool isTracking = true);

       /// <summary>
       /// 根据实体条件获取实体的集合
       /// </summary>
       /// <param name="model"></param>
       /// <returns></returns>
       List<T> GetAll(T model, bool isTracking = true);

       /// <summary>
       /// 根据实体查询分页
       /// </summary>
       /// <param name="model"></param>
       /// <param name="page"></param>
       /// <param name="size"></param>
       /// <param name="total"></param>
       /// <param name="asNoTracking"></param>
       /// <param name="includeTable"></param>
       /// <returns></returns>
       List<T> GetAll(T model, int page, int size, out int total, bool isTracking = true);
    }
}
